import 'package:flutter/material.dart';
import 'package:personinfo/model/home/SearchCarModel.dart';
import 'package:personinfo/utils/ColorUtil.dart';
import 'package:personinfo/widgets/common/CommonWidget.dart';
import 'package:personinfo/widgets/common/MiniTitleNav.dart';
import 'package:personinfo/widgets/common/Vanfeild.dart';

class SelectCarSeries extends StatefulWidget {
  SearchCarModel arguments;
  SelectCarSeries({super.key, required this.arguments});
  @override
  _SelectCarSeriesState  createState() => _SelectCarSeriesState();
}

class _SelectCarSeriesState extends State<SelectCarSeries>  {

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      backgroundColor: Theme.of(context).colorScheme.onPrimary,
      appBar: commonWidget.appBar(
        title: const Text("选择车系"),
        leading: GestureDetector(
          onTap: () {
            Navigator.pop(context);
          },
          child: const Icon(Icons.keyboard_arrow_left),
        )
      ),
      body: Column(
          children: [
            MiniTitleNav(title: widget.arguments?.carBrand ?? "",showMore: false),
            ...[1,2,3].map((index)=> VandInfo(
                labelText: '${widget.arguments.carBrand}$index系',
               onTap: (){
                 setState(() {
                   widget.arguments.carRule = '${widget.arguments.carBrand}$index系';
                 });
                 Navigator.pushReplacementNamed(context, '/publishSearchCar',arguments: widget.arguments);
               },
              color: widget.arguments?.carRule == '${widget.arguments.carBrand}$index系' ? Colors.white : Colors.black,
              backgroundColor: widget.arguments?.carRule == '${widget.arguments.carBrand}$index系' ? ColorUtil.primaryBadgeBgColor : Colors.white,
            )
            ).toList(),
          ]
      ),
    );
  }
}
